//
//  RadiolistheadView.m
//  SunXi
//
//  Created by dllo on 15/11/28.
//  Copyright © 2015年 大远. All rights reserved.
//

#import "RadiolistheadView.h"

@implementation RadiolistheadView

- (void)loadHeadView:(RadioModel *)model{
    
    
    UIImageView *imageView = [[UIImageView alloc]init];
    [self addSubview:imageView];
    CGFloat hei =  SWIDTH / 640  * 280;
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(hei);
        make.width.equalTo(self);
        make.top.equalTo(self.mas_top);
        
    }];
    [imageView sd_setImageWithURL:[NSURL URLWithString:model.coverimg] placeholderImage:[UIImage imageNamed:@"zan"]];
    UIView *footView = [[UIView alloc]init];
    [self addSubview:footView];
    [footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageView.mas_bottom);
        make.bottom.equalTo(self);
        make.left.and.right.equalTo(self);
    }];
    //用户头像
    UIImageView *userImageView = [[UIImageView alloc]init];
    [footView addSubview:userImageView];
    [userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(footView).offset(15);
        make.top.equalTo(footView).offset(10);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(30);
    }];
    userImageView.layer.cornerRadius = 15;
    userImageView.layer.masksToBounds = YES;
    [userImageView sd_setImageWithURL:[NSURL URLWithString:model.userinfo[@"icon"]] placeholderImage:[UIImage imageNamed:@"zan"]];
    //用户名字
    UILabel *userlabel = [[UILabel alloc]init];
    [footView addSubview:userlabel];
    [userlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(footView).offset(15);
        make.left.equalTo(userImageView.mas_right).offset(2);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo([model.userinfo[@"uname"] length] * 15);
    }];
    userlabel.text = model.userinfo[@"uname"];
    userlabel.textColor = BUTTONCOLOR;
    userlabel.font = [UIFont systemFontOfSize:13];
    
    //收听数
    UILabel *countLabel = [[UILabel alloc]init];
    [footView addSubview:countLabel];
    [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(footView).offset(15);
        make.right.equalTo(footView).offset(-15);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(100);
    
    }];
    
    countLabel.text = [NSString stringWithFormat:@"听:%@",model.count];
    countLabel.textColor = [UIColor colorWithRed:0.403 green:0.406 blue:0.388 alpha:0.8];
    countLabel.font = [UIFont systemFontOfSize:13];
    countLabel.textAlignment = NSTextAlignmentRight;
    
    UILabel *label = [[UILabel alloc]init];
    [footView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(userImageView.mas_bottom).offset(10);
        make.right.equalTo(footView).offset(-15);
        make.left.equalTo(footView).offset(15);
        make.bottom.equalTo(footView).offset(- 5);
    }];
    label.text = model.desc;
    label.numberOfLines = 0;
}

@end
